Fix wallet name generation to use explicit public descriptor checksum#482
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #482 +/- ##
==========================================
+ Coverage 80.55% 80.91% +0.35%
==========================================
Files 24 24
Lines 5472 5469 -3
Branches 243 244 +1
==========================================
+ Hits 4408 4425 +17
+ Misses 987 967 -20
Partials 77 77
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| .to_string(); | ||
| let (descriptor, keymap) = descriptor.into_wallet_descriptor(secp, network_kind)?; | ||
| if !keymap.is_empty() { | ||
| return Err(DescriptorError::Miniscript(miniscript::Error::Unexpected( |
There was a problem hiding this comment.
Since there are already dedicated variants for validation rules like this (HardenedDerivationXpub and ExternalAndInternalAreTheSame), would it make sense to add one here so callers can match on this condition without inspecting the message string?
There was a problem hiding this comment.
Thanks, after the comments from @ValuedMammal in #481, this will be removed entirely.
| assert!(result.is_ok()); | ||
|
|
||
| // Test with empty descriptor | ||
| let public_empty = ""; |
There was a problem hiding this comment.
This test returns early at parse_descriptor before keymap.is_empty() is ever checked. It's testing parse error propagation, not the new check. Maybe clarify the comment to reflect that?
There was a problem hiding this comment.
Thanks, This will be removed entirely.
| Err(DescriptorError::Miniscript(Unexpected(..))) | ||
| )); | ||
| // Test with change descriptor containing public keys (should be ok) | ||
| let public_change_without_private = "wpkh([9a6a2580/84'/1'/0']tpubDDnGNapGEY6AZAdQbfRJgMg9fvz8pUBrLwvyvUqEgcUfgzM6zc2eVK4vY9x9L5FJWdX8WumXuLEDV5zDZnTfbn87vLe9XceCFwTu9so9Kks/1/*)"; |
There was a problem hiding this comment.
This is a duplicate of public_change above, as they have same descriptor string. One can be removed.
| @@ -2797,16 +2797,23 @@ where | |||
| T: IntoWalletDescriptor, | |||
| { | |||
| // TODO: check descriptors contains only public keys | |||
There was a problem hiding this comment.
This can be removed now that the check is implemented
3a7cd0d to
11fb999
Compare
…or checksums - Update `wallet_name_from_descriptor` to compute descriptor checksum explicitly - Remove reliance on `to_string()` implicitly containing `#checksum` - Clarify that wallet name is defined by public descriptor checksums - Add regression test for equivalent xpub/xprv wallet names
11fb999 to
ab1d73b
Compare
|
In ab1d73b For clarity you should have somewhere in the test the expected wallet name, for example assert_eq!(public_result.as_ref().unwrap(), "vn4aqs37"); |
Thank you for that, I will update that now. |
|
Since we're touching this part of the code we should make the documentation super clear so users know what to expect
|
|
We should update the PR description as well once you've settled on a direction. If you're using links in the PR description, they're not showing up well 🧐 |
wallet_name_from_descriptor
Will push an update for this. |
…n clear to understand
Summary
Testing
Checklists
All Submissions:
just pbefore pushingCloses #481